<?php

namespace App\Services;

use App\Models\BaseModel;
use App\Models\Park;

class ParkService extends BaseService
{
    /**
     * 停车场列表
     * @return array
     */
    public function list()
    {
        // 设置对象
        $model = Park::query();
        // 状态
        $model = $model->where('status', BaseModel::STATUS_ENABLE);
        // 获取列表
        $list = $model
            ->orderBy('sort', 'desc')
            ->orderBy('id', 'desc')
            ->get(['id', 'park_name', 'park_img', 'lng', 'lat'])
            ->toArray();

        foreach ($list as &$item) {
            $item['park_img'] = storage($item['park_img']);
        }

        return $list;
    }
}
